Back

JavaScript Practice Questions

  1. Write a function that takes an array of numbers and returns a new array with only the prime numbers. Q1
  2. Given an array of objects representing students with name and score, write a function to return the student with the highest score. Q2
  3. Create a webpage with a button. When clicked, the button should toggle the visibility of a paragraph using DOM methods. Q3
  4. Write a JavaScript program using an object to model a car with methods to start, stop, and display its status. Q4
  5. Write a function that takes a sentence and returns the word with the maximum length. Q5
  6. Convert a function that filters out even numbers from an array into an arrow function with concise syntax. Q6
  7. Write a JavaScript program to flatten a nested array (e.g., [1, [2, 3], [4, [5]]] => [1, 2, 3, 4, 5]). Q7
  8. Create a form with email input and submit button. Validate using JavaScript DOM to ensure a valid email format. Q8
  9. Write a function that merges two arrays and removes duplicates without using built-in Set. Q9
  10. Create a nested object to represent a company with departments and employees. Write a function to list all employee names. Q10